package com.wl.application.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

/**
 * @author wl
 * @version 1.0
 * @date 2022/6/15
 * @description:
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class Result {
    /**
     * 返回的状态码
     */
    private Integer code;
    
    /**
     * 返回的信息
     */
    private String msg;
    
    
    /**
     * 返回的参数类型
     */
    private Object data;
    
    
    public static Result ok(){
        return new Result(200,null,null);
    }
    public static Result ok(String msg){
        return new Result(200,msg,null);
    }
    public static Result ok(Object object){
        return new Result(200,null,object);
    }
    public static Result error(){
        return new Result(500,null,null);
    }
    public static Result error(String msg){
        return new Result(500,msg,null);
    }
    public static Result error(Object object){
        return new Result(500,null,object);
    }

    public static Result write(boolean flag){
        return flag?ok():error();
    }
}
